package com.examples.oryarok;

import static com.examples.oryarok.Constants.*;
import static android.provider.BaseColumns._ID;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


public class MeetDataDbHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "meetings.db";
	private static final int DATABASE_VERSION = 1;
	
	// Database creation SQL statement
	private static final String DATABASE_CREATE = "CREATE TABLE " 
							+ TABLE_NAME + " (" 
							+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
							+ DATE + " TEXT NOT NULL," 		//10.10.2011
							+ DAY + " TEXT NOT NULL," 		//Sun - Sat
								+ TIME + " TEXT NOT NULL," 		//21:00
							+ NAME + " TEXT NOT NULL," 		//Yosi Levy
							+ GENDER + " TEXT NOT NULL,"	//m/f
							+ PHONE1 + " TEXT NOT NULL,"	//phone num
							+ PHONE2 + " TEXT,"				//phone num
							+ PHONE3 + " TEXT,"				//phone num
							+ ADDRESS + " TEXT NOT NULL,"	//full address
							+ STATUS + " TEXT NOT NULL,"	//ishur, bitul and ...
							+ TYPE + " TEXT NOT NULL,"		//miphgash, hadracha
							+ NUM_CONTACTS + " INTEGER,"	//num of lidim
							+ NOTE + " TEXT);";			//notes
	
	public MeetDataDbHelper(Context ctx) {
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DATABASE_CREATE);
	}
	/*
	 * Update the database
	 */
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVirsion) {
		db.execSQL("DROP TABLE IF EXIST " + TABLE_NAME);
		onCreate(db);
		
//		if (oldVersion >= newVersion)
//			return;
//
//		String sql = null;
//		if (oldVersion == 1) 
//			sql = "alter table " + TABLE + " add note text;";
//		if (oldVersion == 2)
//			sql = "";
//
//		Log.d("EventsData", "onUpgrade	: " + sql);
//		if (sql != null)
//			db.execSQL(sql);
	}
	
}
